//
//  BBNode.h
//  xNose
//
//  Created by ben smith on 9/7/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

// this is the basic object for each item in the presentation
// the node has a text title
// it can have multiple child nodes
// and it can have a related node

@interface BBNode : NSObject {
	NSMutableArray * children;
	NSMutableArray * connections;

	NSString * title;
	NSString * subtitle;
	NSString * information;
	float cost;
	float income;
	NSString * type;
	BOOL isConnecting;
	BOOL isOpen;
	NSPoint position;
	NSView * view;
	CALayer * layer;
	BBNode * parent;
	NSRect savedFrame;
	BOOL isHidden;
}

@property (assign) 	NSPoint position;

@property (assign) float cost;
@property (assign) float income;

@property (copy) NSString * type;

@property (copy) NSString * title;
@property (copy) NSString * subtitle;
@property (copy) NSString * information;
@property (retain) BBNode * parent;
@property (retain) NSView * view;
@property (retain) CALayer * layer;
@property (assign) BOOL isConnecting;
@property (assign) BOOL isOpen;
@property (assign) BOOL isHidden;
@property (retain) NSMutableArray * children;
@property (retain) NSMutableArray * connections;



+ (BBNode*) collectionNode;;
+ (BBNode*) containerNode;;
+ (BBNode*) leafNode;;
+ (BBNode*) node;;
+ (BBNode*) rootNode;;
- (BBNode*)deepCopy;
- (BBNode*)firstCollection;
- (BBNode*)firstContainer;
- (BBNode*)firstLeaf;
- (BBNode*)hitTest:(NSPoint)p;
- (BBNode*)rootNode;
- (BOOL)hasChildren;
- (BOOL)isCollection;
- (BOOL)isConnectedTo:(BBNode*)aNode;
- (BOOL)isContainer;
- (BOOL)isHidden;
- (BOOL)isLeaf;
- (BOOL)isRoot;
- (BOOL)isSameTypeAs:(BBNode*)aNode;
- (NSInteger)childCount;
- (float)cost;
- (float)income;
- (float)profit;
- (id) init;
- (id)initWithCoder:(NSCoder *)coder;
- (void) dealloc;
- (void)addChild:(BBNode*)aNode;
- (void)addConnection:(BBNode*)aNode;
- (void)clearConnections;
- (void)encodeWithCoder:(NSCoder *)coder;
- (void)hideView;
- (void)insertChild:(BBNode*)aNode atIndex:(NSInteger)index;
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
- (void)openConnected;
- (void)removeChild:(BBNode*)aNode;
- (void)removeConnectedNode:(BBNode*)aNode recurse:(BOOL)recurse;
- (void)removeFromView;
- (void)resetViews:(BOOL)animate;
- (void)shiftViewFrameByX:(float)xShift animate:(BOOL)animate;
- (void)showView;

-(void)setViewScale:(float)scale;

// 40 methods

@end
